package chapter15;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/2/23 11:51
 */
public class FireFlag {
    private volatile boolean fired = false;

    public synchronized void wairForFire() throws InterruptedException {
        while (!fired) {
            System.out.println("wait for signal");
            wait();
        }
    }

    public synchronized void fire() {
        this.fired = true;
        System.out.println("fired");
        notifyAll();
    }
}
